home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 1.2 KB | 61 lines | [TEXT/CWIE] |
- // ContextMaintainer.cp
-
- #ifndef ContextMaintainer_h
- #include "ContextMaintainer.h"
- #endif
- #ifndef Context_h
- #include "Context.h"
- #endif
- #ifndef ListLoop_h
- #include "ListLoop.h"
- #endif
- #ifndef ContextUser_h
- #include "ContextUser.h"
- #endif
-
- ListOf<ContextMaintainer> ContextMaintainer::maintainers;
-
- ContextMaintainer::ContextMaintainer()
- : old( Context::Current() ),
- link( this )
- {
- maintainers.Add( link, afterEnd );
- }
-
- ContextMaintainer::ContextMaintainer( Context *toUse )
- : old( Context::Current() ),
- link( this )
- {
- maintainers.Add( link, afterEnd );
- Context::Set( toUse );
- }
-
- ContextMaintainer::ContextMaintainer( const ContextUser& toUse )
- : old( Context::Current() ),
- link( this )
- {
- maintainers.Add( link, afterEnd );
- toUse.SetContext();
- }
-
- ContextMaintainer::~ContextMaintainer()
- {
- Context::Set( old );
- }
-
- void ContextMaintainer::StopMaintaining( Context *toLose )
- {
- Context *previous = 0;
- for ( ListLoop<ContextMaintainer> loop( maintainers );
- loop.Unfinished();
- loop++ )
- if ( loop->old == toLose )
- loop->old = previous;
- else
- previous = loop->old;
- }
-
- #include "ListLink.cp"
- #include "ListOf.cp"
- #include "ListLoop.cp"
-